<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Pic extends MY_Controller {
    
    var $controller_path 	= '/pic/';
    var $model_path 		= '';
    var $lang_path 			= '';
	
    function __construct()
    {
		parent::__construct();

		log_message('debug', "Index controller Class Initialized.");
    }

    public function up()
    {
        $file_type   = $this->input->post_get("type");
        $file_size   = $this->input->post_get("size");
        $file_hz     = $this->input->post_get("hz");
        //log_message('debug', "data:".print_r($this->input->get_post(),true));

        log_message('debug', "data:".print_r($_FILES,true));
        $config['upload_path']      = "files/pic/";
        $config['allowed_types']    = 'gif|jpg|png';
        $config['file_name']    = uniqid("pic_".date("Ymd_"));
        //$config['max_size']     = 100;
        //$config['max_width']        = 1024;
        //$config['max_height']       = 768;

        @mkdir($config['upload_path'],0777,true);

        $this->load->library('up_lib', $config);

        if ( ! $this->up_lib->do_upload('file'))
        {
            $this->api("304","",$this->up_lib->display_errors("",""));
        }
        $data = $this->up_lib->data();
        $file_path["url"] = $config['upload_path'] . $data["file_name"];
        $file_path["imageUrl"] = $this->pic2url($config['upload_path'] . $data["file_name"]);
        $this->api("200",$file_path,"");
    }

    public function ue()
    {
        $file_type   = $this->input->post_get("type");
        $file_size   = $this->input->post_get("size");
        $file_hz     = $this->input->post_get("hz");
        //log_message('debug', "data:".print_r($this->input->get_post(),true));

        log_message('debug', "data:".print_r($_FILES,true));
        $config['upload_path']      = "files/pic/";
        $config['allowed_types']    = 'gif|jpg|png';
        $config['file_name']    = uniqid("pic_".date("Ymd_"));
        //$config['max_size']     = 100;
        //$config['max_width']        = 1024;
        //$config['max_height']       = 768;

        @mkdir($config['upload_path'],0777,true);

        $this->load->library('up_lib', $config);

        if ( ! $this->up_lib->do_upload('file'))
        {
            $this->api("304","",$this->up_lib->display_errors("",""));
        }
        $data = $this->up_lib->data();
        $file_path["url"] = $config['upload_path'] . $data["file_name"];
        $this->api("200",$file_path,"");
    }


    public function index()
    {
		$this->api("200","","欢迎使用本系统");
    }
}
